<?php

namespace app\common\business\single;

use app\common\model\single\SysSinglePassport as Model;

class SysSinglePassport 
{ 
    /** 
     *【方法注释】获取数据列表 
     *@param $where 查询的条件数组
     *@param $limit_start 获取数据，从第$limit_start条数据开始
     *@param $page_size 获取数据，从第$limit_start条数据开始，取$page_size条数据
     *@param array 返回的数据，数组
     */
    public static function getList($where, $limit_start, $page_size){
        return Model::getList($where, $limit_start, $page_size);
    } 

    /** 
     *【方法注释】获取数据条数 
     *@param $where 查询的条件数组
     *@param int 返回的数据条数
     */
    public static function getCount($where){
        return getAllPage(Model::getCount($where));
    } 

    /** 
     *【方法注释】获取单条数据 
     *@param $where 查询的条件数组
     *@param array 返回的单条数据
     */
    public static function getOne($where){
        return Model::getOne($where);
    } 

    /** 
     *【方法注释】新增数据 
     *@param $receiveData 数组数组
     *@param $admin_name 操作人
     *@param $isFront 是否是前端添加
     *@param bool 数据是否新增成功
     */
    public static function insert($receiveData,$admin_name = '',$isFront = false){
        $data = [
             'uid' => $receiveData['uid'],
             'passport_number' => $receiveData['passport_number'],
             'sign_issue_organization' => $receiveData['sign_issue_organization'],
             'sign_issue_day' => $receiveData['sign_issue_day'],
             'expire_day' => $receiveData['expire_day'],
             'organization_number' => $receiveData['organization_number'],
             'image' => getImage($receiveData['image']),
             'create_time' => date('Y-m-d H:i:s'),
             'status' => $receiveData['status'],
             'update_time' => date('Y-m-d H:i:s'),
             'passport_start_day' => $receiveData['passport_start_day'],
             'passport_end_day' => $receiveData['passport_end_day'],
             'admin_name' => $admin_name,
             'remark' => $receiveData['remark'],
        ];
        Model::insert($data);
        return true;
    } 

    /** 
     *【方法注释】修改数据 
     *@param $receiveData 数组数组
     *@param $isFront 是否是前端添加
     *@param bool 数据是否新增成功
     */
    public static function edit($receiveData,$isFront = false){
        $data = [
             'uid' => $receiveData['uid'],
             'passport_number' => $receiveData['passport_number'],
             'sign_issue_organization' => $receiveData['sign_issue_organization'],
             'sign_issue_day' => $receiveData['sign_issue_day'],
             'expire_day' => $receiveData['expire_day'],
             'organization_number' => $receiveData['organization_number'],
             'image' => getImage($receiveData['image']),
             'status' => $receiveData['status'],
             'update_time' => date('Y-m-d H:i:s'),
             'passport_start_day' => $receiveData['passport_start_day'],
             'passport_end_day' => $receiveData['passport_end_day'],
             'remark' => $receiveData['remark'],
        ];
        Model::where(['id'=>$receiveData['id']])->update($data);
        return true;
    } 
    /** 
     *【方法注释】更改状态 
     *@param $value 结果值
     *@param $load 源数据
     *@param bool 数据是否新增成功
     */
    public static function updateStatus($value,$load){
        Model::where(['id'=>$load['id']])->update([
            'status' => $value,
            'update_time' => date('Y-m-d H:i:s')
        ]);
        return true;
    } 

} 
